package day5;

class Dog{
    public String color;
    public int age;
    public String sex;
    public String category;

    public Dog (String color, int age, String sex, String category){
        this.color = color;
        this.age = age;
        this.sex = sex;
        this.category = category;
    }

    public Dog (String category){
        this.category = category;
    }

    public String toString(){

        System.out.println("种类为:" + category);
        return "颜色:" + this.color + "年龄:" + this.age + "性别:" + this.sex + "类别:" + category;
    }
}

public class Demo2 {

    public static void main(String[] args) {

        Dog dog = new Dog("金毛");
        dog.toString();

        Dog dog2 = new Dog("土狗");
        dog.toString();
    }
}
